Skip to content

Return the liquidity delta from allocate to help with off-chain processing #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

naddison36
Copy link
Collaborator

No description provided.

Copy link
Contributor

@clement-ux clement-ux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good, looks good to me 👍

@naddison36 naddison36 merged commit d731cad into nicka/liquidity-strategies May 30, 2025
2 checks passed
@naddison36 naddison36 deleted the nicka/liquidity-strategies-allocate branch May 30, 2025 10:56
naddison36 added a commit that referenced this pull request Jun 2, 2025
* Added strategies to the ARM

* Changed license to BUSL-1.1

* Added Origin ARM

* Changed to use IERC4626 for lending markets

* Update Natspec

* Validate the market asset is the same as the liquidityAsset

* Added Sonic support
Added OriginARM deploy script for Sonic

* Add Sonic deployments file

* Made the Zapper more generic so it can work with multiple ARMs

* Change addMarket to addMarkets
Updated the Sonic deploy script

* fix: prevent redeeming zero shares in AbstractARM contract

* fix: update maxWithdraw call to use contract address in AbstractARM

* Silo market strategy (#69)

* Sonic ARM contract dependencies

* update Code settings

* Silo market contract

* fix: handle zero shares case before redeeming in AbstractARM contract

* Fet liquidity from the active lending market for claimRedeem if not enough liquidity in the ARM

* Added transfer from ARM to SiloMarket contract for deposit

* Add tests for Origin ARM. (#68)

* feat: setup unit test for Origin ARM

* fix: update requestWithdrawal function to return additional value and ensure MockERC20 burn call

* feat: add unit tests for OriginARM deposit functionality and update DEFAULT_FEE constant

* feat: add setArmBuffer function to manage liquidity asset buffer and emit event on update

* feat: add setDefaultStrategy and deposit modifiers for unit tests in OriginARM

* feat: replace MockStrategy with MockMarket and update related modifiers in tests

* feat: add unit tests for OriginARM market management and enhance modifier functionality

* feat: introduce MockERC4626Market and replace MockMarket in shared tests

* feat: enhance market management by adding support for multiple markets and updating modifiers

* feat: add new modifiers for withdrawal and token swap functionality in Modifiers contract

* feat: add unit tests for total assets functionality in OriginARM contract

* feat: add swapAllOETHForWETH modifier to facilitate token swapping in Modifiers contract

* feat: add unit tests for fee collector and fee management in OriginARM contract

* fix: prevent redeeming zero shares in AbstractARM contract

* feat: add additional tests for fee management and address validation in OriginARM contract

* fix: update maxWithdraw call to use contract address in AbstractARM

* feat: enhance simulateMarketLoss modifier to include maxRedeem calculations

* feat: add unit tests for allocate functionality in OriginARM contract

* feat: add marketLoss modifier to simulate market loss in tests

* feat: add unit tests for claim and deposit functionalities in OriginARM contract

* fix: rename contract to reflect correct functionality for claim and redeem tests

* feat: add unit tests for request redeem functionality in OriginARM contract

* feat: add Sonic configuration and update AddressResolver for new market references

* feat: add shared test setup and modifiers for OriginARM contract

* feat: add Allocated event to track asset allocation in AbstractARM contract

* fix: prevent redeem call with zero shares in AbstractARM contract

* fix: handle zero shares case before redeeming in AbstractARM contract

* feat: enhance testing framework with new modifiers and helper functions for OriginARM contract

* fix: prevent redeem call with insufficient shares in AbstractARM contract

* feat: add MIN_BALANCE constant and update allocation tests for edge cases in Fork_Concrete_OriginARM_Allocate_Test_

* feat: add new test cases for liquidity delta scenarios and update assertions in Allocate.sol

* fix: update SiloMarket to use market address for deposit, withdraw, and redeem functions

* refactor: simplify maxWithdraw and maxRedeem functions to return 0 for non-ARM owners

* feat: add tests for allocation scenarios with SiloMarket integration and update shared setup

* feat: add unit tests for SiloMarket with revert scenarios and setup adjustments

* fmt

* refactor: remove unused imports from unit test files

* refactor: simplify maxWithdraw and maxRedeem functions for clarity

* ARM Harvester (#72)

* Fix maxRedeem

* FIx import breaking build

* Renamed collectRewardTokens to collectRewards

* First cut off the Harvester

* Cleaned up Harvester

* Added Harvester to deploy script

* Updated Sonic contract diagram

* Added magpieQuote Hardhat task

* Added magpieTx Hardhat task

* Remove function sig from Magpie swap data

* only console log the swap data

* wip: add first API test interaction

* rename test function to reflect Magpie swap functionality

* Fix parsing of Magpie data

* Enable ffi

* Got Magpie swap working

* Clean up assembly validation

* Update assembly comments

---------

Co-authored-by: Clément <clemmoller@gmail.com>

* Add invariant test to OriginARM. (#70)

* fix: assign maxShares in maxRedeem function in SiloMarket contract

* fix: update label for siloMarket to Silo Market Adapter in Base_Test_ contract

* test: add VaultInteractions tests for OriginARM contract

* fix: update clean-all target to remove yarn.lock and lcov.info files

* feat: migrate invariant for LidoARM in a separated folder

* feat: add invariant tests and setup for OriginARM with helper contracts

* feat: add ClaimRedeem fork tests for Fork_Concrete_OriginARM contract

* feat: add requestRedeem and timejump modifiers to Modifiers contract

* feat: implement handler_claimRedeem and update request management in TargetFunction and Helpers contracts

* feat: add handler_setARMBuffer function and update ClaimRedeem and Allocate status in TargetFunction

* feat: update SetARMBuffer status to implemented and adjust pct calculation in handler_setARMBuffer function

* feat: update Allocate status to not implemented in TargetFunction contract

* feat: add handler_setActiveMarket function and update market management in TargetFunction and Helpers contracts

* feat: update Allocate status to implemented and add handler_allocate function in TargetFunction contract

* feat: add handler_setPrices function to manage buy and sell prices in TargetFunction contract

* feat: update price handling in TargetFunction contract to improve precision and mimic market behavior

* feat: update price handling and add setCrossPrice function in TargetFunction contract

* feat: add handler_swapExactTokensForTokens function and update liquidity calculations in TargetFunction contract

* feat: add handler for `swapTokensForExactTokens()`.

* feat: add handlers for `collectFees` and `setFee`.

* feat: add logic and handler for `requestOriginWithdrawal`.

* feat: add claimOriginWithdrawals handler and update related logic in TargetFunction and Helpers contracts

* feat: add handler for `donateToARM` and update related logic in TargetFunction and FuzzerFoundry contracts

* WIP

* feat: enhance claimRedeem logic and implement fee collection in TargetFunction contract

* feat: add funding logic for markets in FuzzerFoundry contract

* feat: add console logging toggle in Setup and TargetFunction contracts

* feat: update MockVault and related tests to support multiple tokens

* feat: enhance FuzzerFoundry and Properties contracts with new swap properties and invariants

* feat: add new LP invariants and update deposit/redeem logic in TargetFunction contract

* feat: update funding logic and add assertions for LP balances in FuzzerFoundry and TargetFunction contracts

* feat: update assertLpsAreUpOnly function to include tolerance parameter for balance checks

* feat: enable fail_on_revert in fuzz configuration for improved error handling

* feat: refactor getRandomMarket and getRandomLPsWithRequest functions for improved clarity and efficiency

* feat: refactor random selection functions to use Fisher-Yates shuffle for improved randomness and efficiency

* Made the Harvester's price provider optional (#74)

* Add test for OriginARM Harvester  (#73)

* feat: enhance Harvester tests with additional swap scenarios and helper functions

* fix: correct variable name in allowed slippage validation

* test: add comprehensive tests for Harvester setters and swaps

* feat: enhance collectRewards function to return claimed reward tokens and amounts

* Fix issue on SiloMarket and add more tests onHarvester. (#75)

* feat: enhance Harvester tests with additional swap scenarios and helper functions

* fix: correct variable name in allowed slippage validation

* test: add comprehensive tests for Harvester setters and swaps

* feat: enhance collectRewards function to return claimed reward tokens and amounts

* feat: integrate distribution manager and incentives controller in SiloMarket

* fix: correct import statement for Math utility in Harvester contract

* feat: add Fork_Concrete_Harvester_Collect_Test contract and enhance shared test setup

* Changed setActiveMarket to use balanceOf instead of maxRedeem (#76)

* fix available assets (#77)

* Changed setActiveMarket to use balanceOf instead of maxRedeem

* Change _availableAssets to use previewRedeem instead of maxWithdraw

* Add more fork tests (#78)

* Add WOS token and update related tests for market utilization

* fix: update assertions in allocation tests to use approximate equality

* fix: update minimum shares to redeem in AbstractARM contract

* fix: update minimum shares to redeem in AbstractARM contract

* feat: add balanceOf and previewRedeem functions to SiloMarket contract

* fix: update afterInvariant function to use dynamic minimum shares and improve property_swap_A logic

* fix: update minimum shares to redeem in AbstractARM contract

* Updated SiloMarket Natspec

* Fix Natspec

* removed sender check in previewRedeem

* Added CollectedRewards event

* Added ERC-4626 events to SiloMarket

* Plug `SiloMarket.sol` to Varlamore vault instead of markets. (#81)

* fix: adjust invariant test parameters and refactor setup logic in FuzzerFoundry and Setup contracts

* fix: increase invariant test runs and depth for improved coverage

* fix: update SiloMarket constructor to accept gauge address directly

* fix: update minimum shares to redeem from 10,000 to 10,000,000

* feat: deploy new SiloMarket for Varlamore with gauge integration

* fix: correct balance assertion in harvester test and update MIN_BALANCE constant in AllocateWithAdapter test

* fix: update deposit and swap handler functions to use uint88 for amounts (#82)

* Fix: Change MIN_SHARES_TO_REDEEM from constant to immutable. (#83)

* fix: refactor minSharesToRedeem to be an immutable variable in AbstractARM contract

* fix: add minSharesToRedeem parameter to OriginARM constructor and update related deployments

* fix: update test target to use Fuzzer for improved testing coverage

* fix: format

* feat: add MathComparisons library and integrate it into Properties and TargetFunction contracts

* Removed duplicate _setFee

* Gas improvements

* Remove unused Math import in Harvester

* Renamed Harvester to SonicHarvester

* Added onlyOwner to initialize on SonicHarvester

* Updated Natspec

* Deploy OriginARM proxy (#85)

* Split the Sonic deployment file

* Deployed the Origin ARM proxy

* Updated contract verification for Sonic

* Off-chain components (#87)

* Set first Sonic deploy script as executed

* Added deploy to local node

* Adding logging to Sonic deploy

* Remove setZapper
Renamed old allocate to allocateVault
Added allocate for lending markets
Add ARM name to collectFees

* Changed interface import for Hardhat compilation

* autoRequestWithdraw and autoClaimWithdraw now work with Origin ARM on Sonic
Added Defender Actions to request and claim OS withdrawals

* Added collect fees for Sonic

* Fix deployment issue (#86)

* Refactor deployment scripts to use proxy addresses directly and improve deployment logic for Origin ARM and Holesky

* Remove unused DeployManager variable from UpgradeMainnetScript

* Renamed Zapper contract name

* Fix initialize of CapManager

* setPrice hardhat task to work with OriginARM

* Hardhat and Defender action to collect Silo Rewards

* Added harvestRewards Hardhat task

* Enhance DeployManager and DeployOriginARMScript with improved error handling and initialization logic (#88)

---------

Co-authored-by: Clément <55331875+clement-ux@users.noreply.github.com>

* Fixed gap for backward compatibility (#89)

* Fixed OETH fork tests with new OETH Whale

* Fix collect test to handle expired incentives program and validate token addresses

* Reduced the initial OriginARM cap to 200 S

* Update Magpie router address in SonicHarvester and add setter function

* Refactor SonicHarvester constructor to remove Magpie router parameter and update initialization logic

* Changed setActiveMarket so all shares are redeemed from the active market

* Added a gap to SonicHarvester
Added zero address check to _setMagpieRouter

* Added contract version to Magpie router address comment

* Prettier

* Update slippage parameter type to string in Helpers contract and adjust related logic in Swap tests

* Fix CI (#91)

* Refactor test workflow to include non-invariant and invariant tests for LidoARM

* Refactor Makefile to use $(MAKE) for consistency in test commands

* Comment out requirement for SONIC_URL in _createAndSelectFork function

* Add SONIC_URL to environment variables in foundry-tests job

* Uncomment requirement for SONIC_URL in _createAndSelectFork function

* Increase tolerance in totalAssets assertions for allocation tests

* Update totalAssets assertion to use assertApproxEqAbs for accuracy in LidoARM deposit test

* Refactor totalAssets assertions to use assertApproxEqAbs for improved accuracy in deposit tests

* Add debugging output to non-invariant tests step in CI workflow

* Enhance non-invariant tests step with environment checks for better debugging

* Fix installation command in CI workflow to use 'make install' instead of 'forge soldeer install'

* Fix installation command in CI workflow to use 'make install' instead of 'forge soldeer install'

* Simplify non-invariant tests step by removing unnecessary commands before 'make test'

* Fix formatting in CI workflow for Install Dependencies step

* Fix job name for foundry tests in CI workflow

* Deploy Origin ARM on Sonic (#90)

* Hardhat tasks for Origin ARM (#92)

* Deploy Origin ARM on Sonic

* Changed depositLido to depositARM so it works with OriginARM on Sonic

* Made requestRedeem and claimRedeem work with the origin ARM on Sonic

* swap HH task now works with Origin ARM on Sonic

* hh tasks to request and claim Vault withdrawals now work with Origin ARM on Sonic

* HH snap task now works with Sonic ARM

* Removed unused interfaces in SiloMarket

* Allocate excess liquidity to the lending market after claiming OS withdrawal

* Consistent Solidity pragma (#93)

* N-01 Prefix increment operator ++i to save gas in loops (#95)

* L-09 Don't revert of setting the new active market is the same as the previous market (#94)

* Natspec updates (#97)

* N-22 Update Natspec (#98)

* Natspec updates

* Update Natspec

* Gas optimized allocate (#96)

* More Natspec (#99)

* Added allocateThreshold (#84)

* Added allocateThreshold to AbstractARM

* Fixed allocate unit tests

* Prettier

* Fixed allocate fork tests

* Fixed allocate fork tests

---------

Co-authored-by: Daniel Von Fange <daniel@leancoder.com>

* M-01 Operator Can Steal Rewards From the Harvester (#100)

* SonicHarvester changed so the Magpie swap is sent to the harvester before the recipient

* Fix setActiveMarket unit test

* Script to upgrade the SonicHarvester

* Changes from internal reviews (#101)

* Renamed the upgrade script

* Changed claimRedeem to check if the activeMarket has been configured

* Added view functions convertToShares and convertToAssets to SiloMarket

* Added upgrade of SiloMarket to deploy script

* Fix handling of claiming Lido withdrawals if a withdrawal request is transferred to the LidoARM

* Ensure totalAssets returns at least MIN_TOTAL_SUPPLY

* Setup Origin ARM Defender Actions (#102)

* Updated Sonic ARM contract diagram

* Fixed allocate hardhat task

* Deployed Defender Actions

* Fixed auto claim of OS withdrawals

* Changed collectRewards HH task

* Updated README with Defender ids

* Increase token amounts in swap tests for better coverage

* Increase WETH amounts in swap tests for improved coverage

* Fix totalAssets assertion in requestRedeem test after loss scenario

* Add test for totalAssets after full asset loss in LidoARM

* Return the liquidity delta from allocate to help with off-chain processing (#103)

* Refactor tests to improve coverage and add preview assertions for deposit and redeem functions (#105)

* Deploy 003 - Upgrade Origin ARM on Sonic (#104)

* Fix 003 deploy script

* Deployed 003 script to upgrade OriginARM

* Hard code gas limit of allocate

---------

Co-authored-by: Clément <55331875+clement-ux@users.noreply.github.com>
Co-authored-by: Clément <clemmoller@gmail.com>
Co-authored-by: Daniel Von Fange <daniel@leancoder.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants